//
//  NewTableViewCell.m
//  UI11home
//
//  Created by apple on 15/11/9.
//  Copyright © 2015年 liyinkai. All rights reserved.
//

#import "NewTableViewCell.h"

@implementation NewTableViewCell
- (void)dealloc {
    [_view1 release];
    [_view2 release];
    [_view3 release];
    [_view4 release];
    [super dealloc];
}

//重写初始化方法自定义功能
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        self.backgroundColor = [UIColor redColor];
//        //        超出俯视图边界不显示（yes） -- NO显示
//        self.clipsToBounds = YES;
        [self addSubview:self.view1];
        [_view1 release];
        [self addSubview:self.view2];
        [_view2 release];
        [self addSubview:self.view3];
        [_view3 release];
        [self addSubview:self.view4];
        [_view4 release];

    }
    return self;
}
-(void)layoutSubviews {
    //    每次刷新cell都会执行这个方法
    //    老王小贴士：尽量这个方法里面只写布局
    [super layoutSubviews];
    self.view1.frame = CGRectMake(20, 20, 60, 110);
    self.view2.frame = CGRectMake(110, 20, 60, 110);
    self.view3.frame = CGRectMake(210, 20, 60, 110);
    self.view4.frame = CGRectMake(300, 20, 60, 110);
}
-(UIView *)view1 {
    if (!_view1) {
        self.view1 = [[UIView alloc] init];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        [button setImage:[[UIImage imageNamed:@"1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        button.frame = CGRectMake(0, 0, 60, 60);
        [_view1 addSubview:button];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 75, 60, 25)];
        label.text = @"lwsb";
        label.textAlignment = NSTextAlignmentCenter;
        [_view1 addSubview:label];
        [_view1 release];
    }
    return _view1;
}
-(UIView *)view2 {
    if (!_view2) {
        self.view2 = [[UIView alloc] init];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        [button setImage:[[UIImage imageNamed:@"2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        button.frame = CGRectMake(0, 0, 60, 60);
        [_view2 addSubview:button];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 75, 60, 25)];
        label.text = @"lwsb";
        label.textAlignment = NSTextAlignmentCenter;
        [_view2 addSubview:label];
        [_view2 release];
    }
    return _view2;
}
-(UIView *)view3 {
    if (!_view3) {
        self.view3 = [[UIView alloc] init];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        [button setImage:[[UIImage imageNamed:@"3"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        button.frame = CGRectMake(0, 0, 60, 60);
        [_view3 addSubview:button];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 75, 60, 25)];
        label.text = @"lwsb";
        label.textAlignment = NSTextAlignmentCenter;
        [_view3 addSubview:label];
        [_view3 release];
    }
    return _view3;
}
-(UIView *)view4 {
    if (!_view4) {
        self.view4 = [[UIView alloc] init];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        [button setImage:[[UIImage imageNamed:@"4"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        button.frame = CGRectMake(0, 0, 60, 60);
        [_view4 addSubview:button];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 75, 60, 25)];
        label.text = @"lwsb";
        label.textAlignment = NSTextAlignmentCenter;
        [_view4 addSubview:label];
        [_view4 release];
    }
    return _view4;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
